package com.krediti.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

@Entity
@Table(name = "TIPROCNOSTI")
public class TipRocnosti implements java.io.Serializable {

	/**
	 * Generated serial version.
	 */
	private static final long serialVersionUID = -207062374316612L;
	private Integer id;
	private String naziv;
	private Set<KreditniZahtev> kreditniZahtev = new HashSet<KreditniZahtev>(0);

	public TipRocnosti() {
	}

	public TipRocnosti(Integer id) {
		this.id = id;
	}

	public TipRocnosti(Integer id, String naziv,
			Set<KreditniZahtev> kreditniZahtev) {
		this.id = id;
		this.naziv = naziv;
		this.kreditniZahtev = kreditniZahtev;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TIPROCNOSTI_SEQ")
	@SequenceGenerator(name = "TIPROCNOSTI_SEQ", sequenceName = "TIPROCNOSTI_SEQ")
	@Column(name = "ID", unique = true, nullable = false)
	@NotNull
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "NAZIV", length = 100)
	@Length(max = 30)
	@NotNull
	public String getNaziv() {
		return this.naziv;
	}

	public void setNaziv(String naziv) {
		this.naziv = naziv;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tipRocnosti")
	public Set<KreditniZahtev> getKreditniZahtev() {
		return this.kreditniZahtev;
	}

	public void setKreditniZahtev(Set<KreditniZahtev> kreditniZahtev) {
		this.kreditniZahtev = kreditniZahtev;
	}

}
